package cn.it.hbtt.petoa.entity;

import java.sql.ResultSet;
import java.sql.SQLException;

public class PetStore implements RowMapper{
    private int id;
    private String name;
    private String password;
    private int balance;

    public PetStore() {
    }

    public PetStore(int id, String name,
                    String password, int balance) {
        this.id = id;
        this.name = name;
        this.password = password;
        this.balance = balance;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getBalance() {
        return balance;
    }

    public void setBalance(int balance) {
        this.balance = balance;
    }

    @Override
    public String toString() {
        return "PetStore{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", balance=" + balance +
                '}';
    }

    public PetStore getRow(ResultSet rs) {
        PetStore petStore = null;
        try {
            int id = rs.getInt("id");
            String name = rs.getString("name");
            String password = rs.getString("password");
            int balance = rs.getInt("balance");
            petStore = new PetStore(id,name,password,balance);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return petStore;
    }
}
